import { useMutation, useQuery } from "react-query";
import { useRequest } from "../utils/request";
import { IPage, IPageParams } from "../types";




/**
 * !获取全量矛盾纠纷类型接口
 * @returns 
 */
export const useGetBeefTypeAll = () => {
    const request = useRequest<IBeefType[]>();
    return useQuery(['beefTypeListAll'], () =>
        request('/beefType/getBeefTypeListAll', { data: {} }),
    );
};
/**
 * !搜索矛盾纠纷类型接口
 * @returns 
 */
export const useGetBeefType = (queryParams: IBeefTypeSearchParams) => {
    const request = useRequest<IPage<IBeefType>>();
    return useQuery(['beefTypeList', queryParams], () =>
        request('/beefType/ua/getBeefTypeList', { data: queryParams }),
    );
};

/**
 * !添加矛盾纠纷类型接口
 */
export const useAddBeefType = () => {
    const request = useRequest<string>();
    return useMutation(async (params: IAddBeeftype) => {
        const result = request("/beefType/addBeefType", {
            data: params,
            method: "PUT",
        });
        return result;
    });
}

/**
 * !修改矛盾纠纷类型接口
 */

export const useUpdateBeefType = () => {
    const request = useRequest<string>();
    return useMutation(async (params: IBeefType) => {
        const result = request("/beefType/updateBeefTypeNameById", {
            data: params,
            method: "POST",
        });
        return result;
    });
}

/**
 * !删除矛盾纠纷类型接口
 */
export const useDeletedBeefType = () => {
    const request = useRequest<string>();
    return useMutation(async (params: { beefTypeId: number }) => {
        const result = request("/beefType/deletedBeefTypeById", {
            data: params,
            method: "DELETE",
        });
        return result;
    });
}



export type IAddBeeftype = {
    beefTypeName: string;
}

/**
 * 搜索矛盾纠纷类型参数
 */
export type IBeefTypeSearchParams = {
    beefTypeName: string;
} & IPageParams;


export type IBeefType = {
    /**
     * 矛盾纠纷ID
     */
    beefTypeId: number;

    /**
    * 矛盾纠纷类型名称
    */
    beefTypeName: string;
}